package com.example.campuslink.commen.adpter

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.example.campuslink.BR
import com.example.campuslink.R
import com.example.campuslink.commen.core.CoreAdapter
import com.example.campuslink.commen.core.CoreViewHolder
import com.example.campuslink.commen.tools.CommendEmoji
import com.example.campuslink.databinding.AdapterCommendEmojiBinding
import com.example.campuslink.ui.activity.InvitationDetailActivity
import com.example.campuslink.viewModel.InvitationDetailViewModel
import java.lang.ref.WeakReference

class CommendEmojiAdapter(vm: InvitationDetailViewModel) :
    CoreAdapter<AdapterCommendEmojiBinding, InvitationDetailViewModel, String>(
        BR.data,
        BR.viewModel,
        vm
    ) {
    private var activityRef: WeakReference<InvitationDetailActivity>? = null
    override fun getItemLayoutId(viewType: Int): Int {
        return R.layout.adapter_commend_emoji
    }

    override fun onBindViewHolder(holder: CoreViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        Glide.with(holder.itemView.context).load(CommendEmoji.getEmoji()[mListData[position]])
            .error(R.drawable.ic_empty)
            .into(holder.binding.root.findViewById<ImageView>(R.id.iv_emoji))
        holder.binding.root.setOnClickListener({
            mViewModel?.addEmojiList(mListData[position])
        })

    }
}